package com.sit.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sit.entity.Admin;
import com.sit.entity.Athlete;
import com.sit.mapper.AdminMapper;
import com.sit.mapper.AthleteMapper;
import com.sit.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private AthleteMapper athleteMapper;

    @Autowired
    private AdminMapper adminMapper;
    @Override
    public int checkAthlete(String ano, String password) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("ano",ano);
        Athlete athlete = athleteMapper.selectOne(wrapper);
        System.out.println(athlete.getPassword());
        if(athlete.getPassword().equals(password)){
            return 1;
        }else{return 0;}

    }

    @Override
    public int checkAdmin(String ano, String password) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("admname",ano);
        Admin admin = adminMapper.selectOne(wrapper);
        if(admin.getAdmpwd().equals(password)){
            return 1;
        }else{return 0;}

    }
}
